var ProfileImage = function () {

    var handleValidation_File = function() {
 
        var form = $('#form-file');
        var error = $('.alert-danger', form);
        var success = $('.alert-success', form);
 
        $(':file').fileupload({
            dataType: 'json',
            submit: function (e, data) {
                $(this).fileupload('send', data);
                return false;
            },
            beforeSend: function (e, data) {
                error.hide();
                success.hide();
            },
            done: function (e, response) {
                response = response.result;
                
                if (response.code == 200) {
                    success.find('span').html(response.message);
                    success.show();
                    error.hide();
                    
                    document.location.reload();
                }
                else {
                    error.find('span').html(response.message);
                    error.show();
                    success.hide();
                }
            },
            fail: function (e, response) {
                
                error.find('span').html('Check Your Connection.');
                error.show();
                success.hide();
            }
        });
    }
     
    return {
        //main function to initiate the module
        init: function () {
 
            handleValidation_File();
        }
    };

}();